<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item label="会员名称" prop="memberName">
        <el-input v-model="queryParams.memberName" placeholder="请输入会员名称" clearable style="width: 240px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="dataList">
      <el-table-column label="会员id" prop="memberId" min-width="120" />
      <el-table-column label="会员名称" prop="memberName" min-width="120" show-overflow-tooltip />
      <el-table-column label="会员头像" prop="adviceMsg" min-width="120">
        <template slot-scope="scope">
          <div>
            <el-image style="width: 50px; height: 50px" :src="scope.row.memberImage"
              :preview-src-list="[scope.row.memberImage]">
            </el-image>
          </div>
        </template>
      </el-table-column>
      <!-- <el-table-column label="memberOpenId" prop="memberId" min-width="120" show-overflow-tooltip />
      <el-table-column label="memberUnionId" prop="memberId" min-width="120" show-overflow-tooltip /> -->

      <el-table-column label="开始时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime) }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

  </div>
</template>

<script>
import { memberList } from "@/api/member/member";

export default {
  name: "Member",
  data () {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 角色表格数据
      dataList: [],

      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        memberName: undefined,
      },
    };
  },
  created () {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList () {
      this.loading = true;

      memberList(this.queryParams).then(response => {
        let { rows } = response;

        this.dataList = rows;
        this.total = response.total;
        this.loading = false;
      }
      );
    },
    /** 搜索按钮操作 */
    handleQuery () {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery () {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>